<template>
  <div>
    <el-button @click="locale = 'zh'">zh</el-button>
    <el-button @click="locale = 'en'">en</el-button>
    <div>此处有内容</div>
    <div>{{ t('sayHi') }}</div>
    <div>{{ t('zaoan') }}</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      locale: 'zh',
      message: {
        zh: {
          sayHi: '你好',
          zaoan: '早安管理员, 欢迎回来'
        },
        en: {
          sayHi: 'Hello',
          zaoan: 'Good Morning, Guanliyuan, welcome back'
        }
      }
    }
  },
  methods: {
    t(val) {
      const zidian = this.message[this.locale]
      return zidian[val]
    }
  }
}
</script>

<style>

</style>
